package com.wgc.canal;

import com.rabbitmq.client.Channel;
import com.wgc.canal.config.RabbitConfig;
import com.xpand.starter.canal.annotation.EnableCanalClient;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;

@SpringBootApplication
@EnableCanalClient //声明当前的服务是canal的客户端
public class CanalMain {
    public static void main(String[] args) {
        SpringApplication.run(CanalMain.class,args);
    }
@Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    @Component
    public class RabbitMqListener {
        @RabbitListener(queues = RabbitConfig.RABBIT_QUEUE)
        public void listener(Object message){
            //能够获取到rabbitmq队列中的信息
            System.out.println(message);
        }
    }
  
}
